package com.szzg10.thinking.chapter18;

import java.io.File;
import java.io.FilenameFilter;

public class DirList {

	public static void main(String[] args) {
		String path = DirList.class.getResource("").getPath();
		File file = new File(path);
		
		String[] names = file.list(new DirFilter(".class"));
		for(String element: names) {
			System.out.println(element);
		}
	}
}

class DirFilter implements FilenameFilter {

	private String part;
	
	public DirFilter(String part) {
		this.part = part;
	}
	
	@Override
	public boolean accept(File file, String name) {
		return name.indexOf(part) != -1 ? true : false;
	}
}
